from ast import Dict
from service.das.test import JsonPlaceholderReplacer
from service.setting_service import DataDictionaryService
from views.common.translator import Translator
from views.template_page_view import BasePageTemplateView, FormItemDto


class CommonSettingView(BasePageTemplateView):

    def __init__(self, parent=None):
        t = Translator()
        super().__init__("CommonSettingView", parent=parent)

    def doInitAndUpdate(self):

        # 先返回一个当前持股信息 Echat
        self.addEchatTemplate(
            "当前持股", "home_current_stock", self.exhcangeStockInfo, self.getBaseParam
        )

        # 再返回一个当前持股信息 Table
        self.addTableTemplate(
            "当前持股", "home_current_stock", self.exhcangeStockInfo, self.getBaseParam
        )

    # 用于返回当前的报表数据
    def exhcangeStockInfo(jsonData: str, params: Dict[str, str]) -> str:
        print(f"传入查询的对象信息{params}")
        replacer = JsonPlaceholderReplacer(jsonData)
        return replacer.get_modified_json()

    # 用于标记当前的查询对象
    def getBaseParam() -> Dict[str, str]:
        return {"stockCode": "100001"}
